﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;

namespace GgCarControl
{
    public partial class Main : Form
    {
        public Main()
        {
            InitializeComponent();
        }

        private void dockPanel1_ActiveContentChanged(object sender, EventArgs e)
        {

        }

        private void MenuItem_ST_ZYJHCX_Click(object sender, EventArgs e)
        {
            ToolStripItem menuitem = (ToolStripItem)sender;
            string menuname = menuitem.Name;
            CreateMDIChild(menuitem.Tag.ToString());
        }

        private void CreateMDIChild(string formname)
        {

            if (!IsInParent(formname))
            {
                DockContent child = null;
                if (formname == "ZYJH_ST")
                {
                    child = new ZYJH_ST();
                }
                if (formname == "ZYJH_SR")
                {
                    child = new ZYJH_SR();
                }
                if (formname == "CAR_SR")
                {
                    child = new CAR_SR();
                }
                if (formname == "CAR_ST")
                {
                    child = new CAR_ST();
                }
                if (formname == "DISPATCH_ST")
                {
                    child = new DISPATCH_ST();
                }
                if (formname == "DISPATCH_SR")
                {
                    child = new DISPATCH_SR();
                }
                if (formname == "DISPATCH_ST_STATUS")
                {
                    child = new DISPATCH_ST_STATUS();
                }
                if (formname == "DISPATCH_SR_STATUS")
                {
                    child = new DISPATCH_SR_STATUS();
                }
                if (formname == "SAT_ST")
                {
                    child = new SAT_ST();
                }
                if (formname == "SAT_SR")
                {
                    child = new SAT_SR();
                }
                if (formname == "STATUS2_ST")
                {
                    child = new STATUS2_ST();
                }
                if (formname == "STATUS2_SR")
                {
                    child = new STATUS2_SR();
                }
                if (formname == "ModifySendCard")
                {
                    child = new ModifySendCard();
                }
                if (formname == "CLTCTJ_Form")
                {
                    child = new CLTCTJ_Form();
                }
                if (formname == "AutoSendCarSetForm")
                {
                    child = new AutoSendCarSetForm();
                }
                if (formname == "AutoSendCarStatusForm")
                {
                    child = new AutoSendCarStatusForm();
                }
                child.Show(dockPanel1);
            }
        }
        private bool IsInParent(string formname)
        {
            foreach (DockContent form in this.MdiChildren)
            {
                if (form.Name == formname)
                {
                    form.Activate();
                    return true;
                }
            }
            return false;
        }

        private void MenuItem_SR_ZYJHCX_Click(object sender, EventArgs e)
        {
            ToolStripItem menuitem = (ToolStripItem)sender;
            CreateMDIChild(menuitem.Tag.ToString());
        }

        private void ToolStripMenuItem_car_sr_Click(object sender, EventArgs e)
        {
            ToolStripItem menuitem = (ToolStripItem)sender;
            CreateMDIChild(menuitem.Tag.ToString());
        }

        private void ToolStripMenuItem_car_st_Click(object sender, EventArgs e)
        {
            ToolStripItem menuitem = (ToolStripItem)sender;
            CreateMDIChild(menuitem.Tag.ToString());
        }

        private void ToolStripMenuItem_dispatch_st_Click(object sender, EventArgs e)
        {
            ToolStripItem menuitem = (ToolStripItem)sender;
            CreateMDIChild(menuitem.Tag.ToString());
        }

        private void ToolStripMenuItem_Dispatch_sr_Click(object sender, EventArgs e)
        {
            ToolStripItem menuitem = (ToolStripItem)sender;
            CreateMDIChild(menuitem.Tag.ToString());
        }

        private void ST_STATUS_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripItem menuitem = (ToolStripItem)sender;
            CreateMDIChild(menuitem.Tag.ToString());
        }

        private void SR_STATUS_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripItem menuitem = (ToolStripItem)sender;
            CreateMDIChild(menuitem.Tag.ToString());
        }

        private void SAT_ST_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripItem menuitem = (ToolStripItem)sender;
            CreateMDIChild(menuitem.Tag.ToString());
        }

        private void SAT_SR_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripItem menuitem = (ToolStripItem)sender;
            CreateMDIChild(menuitem.Tag.ToString());
        }

        private void STATUS2_ST_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripItem menuitem = (ToolStripItem)sender;
            CreateMDIChild(menuitem.Tag.ToString());
        }

        private void STATUS2_SR_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripItem menuitem = (ToolStripItem)sender;
            CreateMDIChild(menuitem.Tag.ToString());
        }

        private void sendCardModifyTSMI_Click(object sender, EventArgs e)
        {
            ToolStripItem menuitem = (ToolStripItem)sender;
            CreateMDIChild(menuitem.Tag.ToString());
        }

        private void AutoSendCarSetTSMI_Click(object sender, EventArgs e)
        {
            ToolStripItem menuitem = (ToolStripItem)sender;
            CreateMDIChild(menuitem.Tag.ToString());
        }

        private void AutoSendCarStatusTSMI_Click(object sender, EventArgs e)
        {
            ToolStripItem menuitem = (ToolStripItem)sender;
            CreateMDIChild(menuitem.Tag.ToString());
        }

        private void Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            Application.ExitThread();
            Application.Exit();
        }
    }
}
